<?php
$emailid=$_REQUEST['editmessage'];

$msgEditScat="";
if(isset($_POST['Submit']))
 {
	$subject=$_REQUEST['subject'];		
	$body=$_REQUEST['content'];
	$today=date("Y-m-d");
	if($emailid=="")
	{		
	$sql_editemail="insert into tbl_customemailmessage set title='$subject',content='$body'";
	$rst_editemail=mysql_query($sql_editemail) or die(mysql_error());	
	$msgEditScat="Message Added Successfully";
	}
	else
	{
	$sql_editemail="Update tbl_customemailmessage set title='$subject',content='$body' where id=$emailid";
	$rst_editemail=mysql_query($sql_editemail) or die(mysql_error());	
	$msgEditScat="Message Edited Successfully";
	}
	
 }
 $email_subject="";
 $email_body="";
 if($emailid)
 {
$sqlEmail="select * from tbl_customemailmessage where id='".$emailid."'";
$rstEmail=mysql_query($sqlEmail);
$rowEmail=mysql_fetch_array($rstEmail);
$email_subject=$rowEmail['title'];
$email_body=$rowEmail['content'];
 }
?>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect",
		
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "js/template_list.js",
		external_link_list_url : "js/link_list.js",
		external_image_list_url : "js/image_list.js",
		media_external_list_url : "js/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
</script>
<table width="100%"  border="1" cellspacing="0" class="container">
  <tr>
    <td width="469" height="25" class="tdHeader">Edit Custom</td>
  </tr>
  <tr>
    <td  height="577">
	<br><br>
          <form action="" method="post" name="formEditSubCat" id="formEditSubCat">
		  
           <table width="100%" border="0" cellspacing="0" align="center">
          <tr>
            <td height="40" colspan="3"><div align="center"><?php if($msgEditScat!="") {echo "<b>".$msgEditScat."</b>"; }?></div></td>
            
          </tr>
		 
		
          <tr>
            <td height="29">&nbsp;</td>
            <td><div align="left">Custom Subject</div></td>
            <td>
              <div align="left">
                <input type="text" name="subject" id="subject" value="<?php echo $email_subject; ?>">
              </div></td>
          </tr>
		   <tr>
            <td height="31">&nbsp;</td>
            <td>Custom Content</td>
            <td><textarea name="content" cols="55" rows="15" id="content"><?php echo $email_body; ?></textarea></td>
           </tr>		  
		  <tr>
            <td height="65" colspan="3"><div align="center">
                <input name="Submit" type="submit" value="Submit" class="button">
              </div></td>
         </tr>
        </table>
       </form>
     </td>
  </tr>
</table>

